<template>
  <div>
    <el-dialog
      v-model="store.state.HomeModule.dialogFormVisible"
      title="外来车辆信息"
    >
      <el-form :model="form">
        <el-form-item label="来访车辆牌号" :label-width="formLabelWidth">
          <el-input
            v-model="form.Carnum"
            autocomplete="off"
            placeholder="来访车辆牌号"
          />
        </el-form-item>
        <el-form-item label="入区时间" :label-width="formLabelWidth">
          <el-input
            v-model="form.Cometime"
            autocomplete="off"
            placeholder="入区时间"
          />
        </el-form-item>
        <el-form-item label="离区时间" :label-width="formLabelWidth">
          <el-input
            v-model="form.Gotime"
            autocomplete="off"
            placeholder="离区时间"
          />
        </el-form-item>
        <el-form-item label="入区目的" :label-width="formLabelWidth">
          <el-input
            v-model="form.Doing"
            autocomplete="off"
            placeholder="入区目的"
          />
        </el-form-item>
      </el-form>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="closeDialog(0)">放弃更改</el-button>
          <el-button type="primary" @click="closeDialog(1)">
            提交更改
          </el-button>
        </span>
      </template>
    </el-dialog>
  </div>
</template>

<script lang="ts" setup>
import { reactive, ref, onMounted } from "vue";
import { useStore } from "vuex";
import link from "@/api/link.js";
import apiUrl from "@/api/url.js";
let store = useStore();
const closeDialog = (num: number) => {
  //提交更改
  if (num === 1) {
    store.commit("DIALOG");
    let datas = {
      Carnum: form.Carnum,
      Cometime: form.Cometime,
      Gotime: form.Gotime,
      Doing: form.Doing,
    };
    link(
      apiUrl.ForeignVehicles + "/" + store.state.HomeModule.uplistData,
      "post",
      datas
    ).then((resolve: any) => {
      console.log(resolve);
    });
  } else {
    //放弃更改
    store.commit("DIALOG");
  }
};
//表单宽度
const formLabelWidth = "200px";
//表单数据
const form = reactive({
  Carnum: "",
  Cometime: "",
  Gotime: "",
  Doing: "",
});
</script>
<style scoped>
.el-button--text {
  margin-right: 15px;
}
.el-select {
  width: 300px;
}
.el-input {
  width: 300px;
}
.dialog-footer button:first-child {
  margin-right: 10px;
}
</style>
